package top.zhangjianyong.blog.manage.controller;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.zhangjianyong.blog.annotation.Permission;
import top.zhangjianyong.blog.enums.RoleKeys;
import top.zhangjianyong.blog.params.tag.TagListParam;
import top.zhangjianyong.blog.params.tag.TagPageParam;
import top.zhangjianyong.blog.params.tag.TagRemoveParam;
import top.zhangjianyong.blog.params.tag.TagSaveParam;
import top.zhangjianyong.blog.params.tag.TagUpdateParam;
import top.zhangjianyong.blog.response.ApiResponse;
import top.zhangjianyong.blog.service.TagService;

/**
 * 标签
 *
 * @author HDN
 * @since 2024/7/30 下午10:49
 */
@RequestMapping("/tag")
@RestController
@Permission(roles = {RoleKeys.ADMIN})
public class TagController {
  private final TagService tagService;

  public TagController(TagService tagService) {
    this.tagService = tagService;
  }

  @PostMapping("/page")
  public ApiResponse page(@RequestBody @Validated TagPageParam param) {
    return tagService.page(param);
  }

  @PostMapping("/save")
  public ApiResponse save(@RequestBody @Validated TagSaveParam param) {
    return tagService.save(param);
  }

  @PostMapping("/update")
  public ApiResponse update(@RequestBody @Validated TagUpdateParam param) {
    return tagService.update(param);
  }

  @PostMapping("/list")
  public ApiResponse list(@RequestBody @Validated TagListParam param) {
    return tagService.list(param);
  }

  @PostMapping("/remove")
  public ApiResponse remove(@RequestBody @Validated TagRemoveParam param) {
    return tagService.remove(param);
  }
}
